package auxx;

import java.util.Random;

public class NumberPro{

        private NumberPro () {}
        private static Random r = new Random();

	public static byte getBit(int n,int position) {
		int aux = 1;
		aux *= Math.pow(2, position-1);
		int bit = aux & n;
		if (bit>0) return 1;
		else return 0;
	}

	public static int setBit(int n, int position, boolean bit) {
		int aux = 1;
		aux *= Math.pow(2, position-1);
		if(bit) {
			n |= aux;
		}
		else {
			aux = ~aux;
			n &= aux;
		}
                return n;
	}
        
        public static int random(int from,int to) {
            if(from==to) return to;
            return r.nextInt(to-from)+from;
        }
}